﻿//
// IObjectContext.cs
//
// Authors:
//    Claus Jørgensen <10229@iha.dk>
//
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data.Linq;
using System.Data.Objects;
using System.Diagnostics.Contracts;

namespace RSD.Data
{
    /// <summary>
    /// Provides facilities for querying and working with entity data as objects.
    /// </summary>
    public interface IObjectContext : IDisposable
    {
        /// <summary>
        /// Creates a new <see cref="T:IObjectSet"/> instance that is used
        /// to query, add, modify, and delete objects of the specified entity type.
        /// </summary>
        /// <typeparam name="TEntity">Entity type of the requested <see cref="T:IObjectSet"/>.</typeparam>
        /// <returns>
        /// The new <see cref="T:IObjectSet"/> instance.
        /// </returns>
        IObjectSet<TEntity> CreateObjectSet<TEntity>()
            where TEntity : class;

        /// <summary>
        /// Persists all updates to the data source and resets change tracking in the
        /// object context.
        /// </summary>
        /// <returns>
        /// The number of objects in an <see cref="F:System.Data.EntityState.Added"/>,
        /// <see cref="F:System.Data.EntityState.Modified"/>, or
        /// <see cref="F:System.Data.EntityState.Deleted"/> state when
        /// <see cref="M:System.Data.Objects.ObjectContext.SaveChanges"/> was called.
        /// </returns>
        /// <exception cref="T:System.Data.OptimisticConcurrencyException">
        /// An optimistic concurrency violation has occurred in the data source.
        /// </exception>
        int SaveChanges();
    }
}
